package com.edu.exam.enums.grading;

/**
 * 配置数据类型枚举
 */
public enum ConfigDataType {
    STRING("STRING", "字符串"),
    INTEGER("INTEGER", "整数"),
    LONG("LONG", "长整数"),
    DOUBLE("DOUBLE", "双精度浮点数"),
    BOOLEAN("BOOLEAN", "布尔值"),
    DATETIME("DATETIME", "日期时间"),
    JSON("JSON", "JSON对象"),
    ARRAY("ARRAY", "数组"),
    FILE("FILE", "文件"),
    ENUM("ENUM", "枚举");

    private final String code;
    private final String description;

    ConfigDataType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static ConfigDataType fromCode(String code) {
        for (ConfigDataType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return STRING; // 默认返回字符串
    }
}